package com.huifaapp.mall.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.huifaapp.mall.R;
import com.huifaapp.mall.adapter.MyCollectAdapter;
import com.huifaapp.mall.fragment.BabyFragment;
import com.huifaapp.mall.fragment.ShopFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * 我的收藏
 * Created by Administrator on 2017/12/19.
 *
 */

public class MyCollectActivity extends AppCompatActivity {

    private ImageView iv_myCollect_back;
    //    private PullToRefreshGridView gv_myCollect;
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private List<Fragment> fragments = new ArrayList<>();
    private List<String> list = new ArrayList<>();



    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_collect);

        initView();
        list.add("宝贝");
        list.add("店铺");
        MyCollectAdapter myCollectAdapter = new MyCollectAdapter(getSupportFragmentManager(),fragments,list);
        viewPager.setAdapter(myCollectAdapter);
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setTabsFromPagerAdapter(myCollectAdapter);

//        gv_myCollect= (PullToRefreshGridView) findViewById(R.id.gv_myCollect);
//        MyCollectGridViewAdapter adapter=new MyCollectGridViewAdapter(MyCollectActivity.this);
//        gv_myCollect.setAdapter(adapter);
    }

    private void initView() {
        iv_myCollect_back= (ImageView) findViewById(R.id.iv_myCollect_back);
        tabLayout = (TabLayout) findViewById(R.id.collect_tab_layout);
        viewPager = (ViewPager) findViewById(R.id.collect_viewpager);
        fragments.add(new BabyFragment());
        fragments.add(new ShopFragment());
        iv_myCollect_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
